/**
 * author      : dormi330
 * date        : 2018/6/26
 * project     : mybatis
 * description : adaptor 商品服务
 */

package com.deep.trade.adaptor.required.sku;

import com.deep.trade.adaptor.required.IdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ItemSkuService {
    private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
    private Map<String, Sku> itemSkuMap = new HashMap<>();

    public Sku skuOfId(String tenantCode, String skuId) {
        return itemSkuMap.get(skuId);
    }

    public List<Sku> skuOfIds(String tenantCode, List<String> skuIdList) {
        return null;
    }

    @PostConstruct
    public void init() {
        Sku sku1 = new Sku(
                IdService.TENANT_CODE,
                IdService.SKU_1_ID,
                IdService.SELLER_1_ID,
                "seller1",
                IdService.SHOP_1_ID,
                IdService.ITEM_1_ID,
                "item_name_1",
                IdService.BRAND_ID,
                IdService.SKU_1_CODE,
                new BigDecimal("100"));

        Sku sku2 = new Sku(
                IdService.TENANT_CODE,
                IdService.SKU_2_ID,
                IdService.SELLER_1_ID,
                "seller1",
                IdService.SHOP_1_ID,
                IdService.ITEM_1_ID,
                "item_name_1",
                IdService.BRAND_ID,
                IdService.SKU_2_CODE,
                new BigDecimal("100"));

        Sku sku3 = new Sku(
                IdService.TENANT_CODE,
                IdService.SKU_3_ID,
                IdService.SELLER_2_ID,
                "seller2",
                IdService.SHOP_2_ID,
                IdService.ITEM_2_ID,
                "item_name_2",
                IdService.BRAND_ID,
                IdService.SKU_3_CODE,
                new BigDecimal("100"));

        Sku sku4 = new Sku(
                IdService.TENANT_CODE,
                IdService.SKU_4_ID,
                IdService.SELLER_2_ID,
                "seller2",
                IdService.SHOP_2_ID,
                IdService.ITEM_2_ID,
                "item_name_2",
                IdService.BRAND_ID,
                IdService.SKU_4_CODE,
                new BigDecimal("100"));


        itemSkuMap.put(sku1.getId(), sku1);
        itemSkuMap.put(sku2.getId(), sku2);
        itemSkuMap.put(sku3.getId(), sku3);
        itemSkuMap.put(sku4.getId(), sku4);

        logger.warn("ItemService 初始化, 添加测试数据 ");
    }


}
